<html>
    <head>
        <script type="text/javascript" src="/Core/jquery-1.2.6.js"></script>
        <script type="text/javascript" src="/Core/jstest.js"></script>
        
        <style type="text/css">
            .fixture_list { padding-left:10px; list-style-type: none; }
            .fixture { }            
            .test_list { list-style-type:disc; }
            .failed_test_li { color:Red; }            
            .failed_test_text { color:Red; }
            .passed_test_li { color:Green; }
            .passed_test_text { color:Black; }
        </style>  
    </head>
    <body>
        <h4>Assertion tests</h4>
        
        <div id="outputDiv" style="font-family:Verdana; font-size:10pt; border:1px solid gray">
        </div>        
        
        <script type="text/javascript">
            $(document).ready( function() {

            function assertInternal(expr, msg) {
                if (expr)
                    console.log("ok: " + assertInternal.caller.name + ", " + assertInternal.caller.caller.name);
                else
                    console.error("FAILED: " + assertInternal.caller.name + ", " + assertInternal.caller.caller.name);
            }

            function assertEqInternal(expected, actual) {
                if (expected === actual)
                    console.log("ok: " + assertEqInternal.caller.name + ", " + assertEqInternal.caller.caller.name);
                else
                    console.error("FAILED: " + assertEqInternal.caller.name + ", " + assertEqInternal.caller.name + " -> expected: " + expected + ", actual: " + actual);
            }
            
            
            function shouldPass(test) {
                var passed = true;
                try {
                  test();
                }
                catch(ex) { passed = false; }
                
                assertInternal(passed);
            }
            
            function shouldFail(test) {
                var passed = false;
                try {
                  test();
                }
                catch(ex) { passed = true; }
                
                assertInternal(passed);
            }
            
            (function equality() {                
                
                shouldPass(function() { verify("this string").is("this string");  } );
                shouldFail(function() { verify("this string").is("not this string");  } );
                
            })();
            
            (function non_equality() {
                shouldPass(function() { verify("this string").is_not("this other string");  } );
                shouldFail(function() { verify("this string").is_not("this string"); } );
            })();
            
            (function contains() {
                shouldPass(function() { verify([1,2,3]).contains(2); } );
                shouldFail(function() { verify([1,2,3]).contains(7); } );
                
                shouldPass(function() { verify("abc").contains("bc"); } );                
                shouldFail(function() { verify("abc").contains("z"); } );
            })();
            
            (function does_not_contain() {
                shouldPass(function() { verify([1,2,3]).does_not_contain(13); } );
                shouldFail(function() { verify([1,2,3]).does_not_contain(2); } );
                
                shouldPass(function() { verify("abc").does_not_contain("z"); } );                
                shouldFail(function() { verify("abc").does_not_contain("bc"); } );
            })();
                       
            
            });
        
        </script>
    </body>
</html>


